import draw.*;
import colors.*;
import geometry.*;
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
/*
Homework Two
CSU213 Proulx
Adam Blackwell
  8333
James Morin  
  9579
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------  
2 Designing Classes
Portfolio Problems
Work out as complete programs the following exercises from the textbook:
Problems:
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
1. Problem 2.4 on page 17
// Exercise 2.4
/* 
  +---------------------------------+
  |            Automobile           |
  +---------------------------------+
  |String         model             |
  |int            price (in dollars)|
  |double         mileage           |
  |               (miles per gallon)|
  |boolean        used              |
  +---------------------------------+
*/
// Translate the class diagram in figure 6 into a class definition.
//Also create instances of the class.

class Automobile {
 String model;
 int price;
 double mileage;
 boolean used;

 Automobile(String model, int price, double mileage, boolean used){
   this.model = model;
   this.price = price;
   this.mileage = mileage;
   this.used = used;
 }
}

class AutomobileExamples{
 Automobile mycar = new Automobile("MyModel", 4500, 30, true);
 Automobile yourcar = new Automobile("YourModel", 70000, 75, false);

 AutomobileExamples(){}
 }
/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
2. Problem 3.1 on page 25
Exercise 3.1
Design a data representation for this problem:

  ...Develop a "real estate assistant" program. The "assistant" helps real
  estate agents locate available houses for clients. The information about
  a house includes its kind, the number of rooms, its address, and the
  asking price. An address consists of a street number, a street name,
  and a city.

Represent the following examples using your classes:
1. Ranch, 7 rooms, $375,000, 23 Maple Street, Brookline;
2. Colonial, 9 rooms, $450,0000, 5 Joye Road, Newton; and
3. Cape, 6 rooms, $235,000, 83 Winslow Road, Waltham
*/
class realEstate{
 String kind;
 int rooms;
 String address;
 String city;
 int price;

 realEstate(String kind, int rooms, String address, String city, int price){
   this.kind = kind;
   this.rooms = rooms;
   this.address = address;
   this.city = city;
   this.price = price;
 }
}

class realEstateExamples{
 realEstate ex1 = new realEstate("Ranch", 7, "23 Maple Street",
                                 "Brookline", 375000);
 realEstate ex2 = new realEstate("Colonial", 9, "5 Joye Road", 
                                 "Newton", 450000);
 realEstate ex3 = new realEstate("Cape", 6, "83 Winslow Road", 
                                 "Waltham", 235000);

 realEstateExamples(){
 }
}
/*
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------   
3. Problem 4.4 on page 33
Exercise 4.4
Design a data reprentation for this problem:

Develop a "bank account" program. The program keeps track of the balances
in a person's bank accounts. Each account has an id number and a customer's
name. There are three kinds of accounts: a checking account, a savings account,
and a certificate of deposit (CD). Checking account information also includes
the minimum balance. Saving account includes the interest rate. A CD specifies
the interest rate and the maturity date. Naturally, all three types come with
a current balance...

Represent the following examples using your classes:
1. Earl Gray, id# 1729, has $1,250 in checking account with minimum
balance of $500;
2. Ima Flatt, id# 4104, has $10,123 in a certifcate of deposit whose
interest rate is 4% and whose maturity date is June 1, 2005;
3. Annie Proulx, id# 2992, has $800 in a savings account; the account
yields interest at the rate of 3.5%
 
*/


interface IAcct{}

class Checking implements IAcct{
  int minBalance;
  int balance;
  
  Checking(int minBalance, int balance){
  this.minBalance = minBalance;
  this.balance = balance;
  }
}

class Savings implements IAcct{
  double interest;
  int balance;
  
  Savings(double interest, int balance){
    this.interest = interest;
    this.balance = balance;
  }
}

class CD implements IAcct{
  double interest;
  Date d;
  int balance;
  
  CD(double interest, Date d, int balance){
    this.interest = interest;
    this.d = d;
    this.balance = balance; 
  }
  
}

class Date{
  int Month;
  int Day;
  int Year;
  
  Date(int Month, int Day, int Year){
    this.Month = Month;
    this.Day = Day;
    this.Year = Year;
  }
}

class bankAccount{
  int id;
  String customer;
  IAcct account;
  
  bankAccount(int id, String customer, IAcct account){
    this.id = id;
    this.customer = customer;
    this.account = account;
  }
}

class bankAccountExamples{
  bankAccount ex1 = new bankAccount(1729, "Earl Gray", new Checking(500, 1250));
  bankAccount ex2 = new bankAccount(4104, "Ima Flatt", new CD(4, new Date(6, 1, 2005), 10123));
  bankAccount ex3 = new bankAccount(2992, "Annie Proulx", new Savings(3.5, 800));
  
  bankAccountExamples(){}
}


/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
4. Problem 5.3 on page 44
Exercise 5.3
Consider a revision of the problem in exercise 3.1

  ...Develop a program that assists the real estate agents. The program deals
  with listings of available houses...

Make examples of listings. Develop a data definition for the listings of houses.
Implement the definition with classes. Translate the examples into objects.
*/



/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
5. Problem 5.9 on page 51
Exercise 5.9
Soccer leagues arrange its soccer teams into phone trees so that they can
quickly inform all parents about rain-outs. The league calls the coach,
who in turn calls the parents of the team captain. Each parent then calls
at most two other parents.
The class diagram in figure 28 (pg.51) contains the data definition for
a program that managages phone trees. Given these classes, one could
create the data in figure 29 (pg.52). Draw the phone tree there as a
circle-and-arrow diagram. Each circle corresponds to a player or coach.
An arrow means that a player calls some other player; it goes from the
caller to the callee. Then develop the class definitions that correspond
to the given data defintion.
*/

/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
6. Problem 10.2 on page 97
Exercise 10.2
Develop the following methods for the class House from exercise 3.1
1. isBigger, which determines whether one house has more rooms than
some other house;
2. thisCity, which checks whether the advertised house is in some
given city (assume we give the method a city name)
3. sameCity, which determines whether one house is in the same city
as some other house.
Before you design the method, draw a complete class diagram for House (by hand)
*/

/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
7. Problem 10.5 on page 105
Exercise 10.5
Modify the Coffee class from figure 38 so that cost takes into account
bulk discounts:
   ...Develop a program that computes the cost of selling bulk coffee
   at a specialty coffee seller from a receipt that includes the kind
   of coffee, the unit price, and the total amount (weight) sold.
   If the sale is for less than 5,000 pounds, there is no discount.
   For sales of 5,000 pounds to 20,000 pounds, the seller grants a
   discount of 10%. For sales of 20,000 pounds or more, the discount
   is 25%...
Don't forget to adapt the examples, too!
*/

/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
8. Problem 14.1 on page 140
Exercise 14.1
Use the libraries you have come to know(colors, draw, geometry) to draw:
(1)a box-and-circles car;
(2)a match-stick man;
(3)a house in ProfessorJ's interactions window.
*/

/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
9. Problem 14.7 on page 144
Exercise 14.7
A software house that is working with a grocery chain receives this
problem statement:
  ...Develop a program that keeps track of the items in the grocery
  store. For now, assume that the store deals only with ice cream,
  coffee, and juice. Each of the items is specified by its brand name
  (String), weight (grams), and price (cents). Each coffee is also
  labeled as either regular of decaffeinated. Juice items come in
  different flavors, and can be packaged as frozen, fresh, bottled,
  or canned. Each package of ice cream specifies its flavor...

Design the following methods:
1. unitPrice, which computes the unit price (cents per gram) of a
grocery item;
2. lowerUnitPrice, which determines the unit price of a grocery
item is lower than some given amount;
3. cheaperThan, which detemines whether a grocery item's unit price
is less than some other (presumably) comparable item's unit price.
*/  
  
/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
Pair Programming Assignment:
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
2.1 Problem
A. Convert the data representation for the US cities from the previous
assignment to data definitions in Beginner ProfessorJ language. (Class
City)
  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
B. Make sure you have a separate class Loc for the location given in the
latitude and longitude coordinates.
*/

class Loc {
  double lon;
  double lat;
  Loc (double lon, double lat){
    this.lon = lon;
    this.lat = lat;
  }
}

class LocExamples {
  Loc l1 = new Loc(45.000,72.000);
  Loc l2 = new Loc(45.000,72.000);
  Loc l3 = new Loc(45.000,72.000);
  LocExamples() {
    super();
  }
}

/*  
*/

class City {
  String name;
  String state;
  int zip;
  Loc loc;
  City (String name, String state, int zip, Loc loc){
    this.name = name;
    this.state = state;
    this.zip = zip;
    this.loc = loc;
  }
}
  
class CityExamples extends LocExamples{
  City Boston = new City ("Boston","MA",2115,l1);
}
/*
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------   
C. Define the class hierarchy that represent a list of cities. Followthe DE-
SIGN RECIPE FOR DATA DEFINITIONS. Remember to make examples
of data.
  Page 40
*/

interface ILos {}

class MTLos implements ILos {
  MTLos() {}
}

class ConsLos implements ILos {
  City fst;
  ILos rst;
  ConsLos(City fst, ILos rst){
    this.fst = fst;
    this.rst = rst;
  }
}

class LosExamples extends CityExamples{
  ILos los1 = new ConsLos(Boston, new ConsLos(Boston, new MTLos()));
  LosExamples() {
    super();
  }
}
  
/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
D. Define the class hierarchy that represents that represent a list of states
identified by a String (typically two lettersthe same format as is
used in the City class. Follow the DESIGN RECIPE FOR DATA DEFI-
NITIONS. Remember to make examples of data.
*/

interface ILost {}

class MTLost implements ILost {
  MTLost() {}
}

class ConsLost implements ILost {
  String fst;
  ILost rst;
  ConsLost(String fst, ILost rst){
    this.fst = fst;
    this.rst = rst;
  }
}

class LostExamples {
  ILost lost1 = new MTLost();
  ILost lost2 = new ConsLost("MA", new ConsLost("MA",new MTLost()));
}
  
/* 
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
2.2 Problem
Design the classes to represent shapes we may want to draw on the Canvas.
We have circles, disks, rectangles, lines, and a combination of shapes - one
on the top, another on the bottom.
Here is what you need to know about each of the shapes:
 A circle has the position of the center, the radius, and a color.
 A disk has the position of the center, the radius, and a color.
 A rectangle has the position of the NW corner, the height and the
width, as well as a color.
 A line has the position of the start and end points and a color.
 A combo shape consists of the top and the bottom shape.
A. Draw a class diagram of class hierarchy that represent shapes.
  Why... This is in the book...
*/

//class 
  
/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
B. Define a class CartPt to represent a Cartesian point with integer co-
ordinates.
  Page 46...
*/
 
class CartPt {
  int x;
  int y;
  CartPt(int x, int y){
    this.x = x;
    this.y = y;
  }
  Posn toPosn(){
    return new Posn(this.x,this.y);
  }
}

/* 
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
C. Define the classes that represent shapes. Use the CartPt class to
represent the positions of shapes. Use the String type to represent
the colors of the shapes.
*/

interface IShape {}

class Dot implements IShape {
  CartPt loc;
  String col;
  Dot(CartPt loc,String col){
    super();
  }
}

class Shape implements IShape {
  CartPt loc;
  String col;
  
  Shape(CartPt loc, String col){
    this.loc = loc;
    this.col = col;
  }
}

class Square extends Shape {
  int size;
  Square(CartPt loc, String col, int size){
    super(loc, col);
    this.size = size;
  }
}

class Rectangle extends Shape {
  int height;
  int width;
  Rectangle(CartPt loc, String col, int height, int width){
    super(loc, col);
    this.height = height;
    this.width = width;
  }
}

class Circle extends Shape {
  int radius;
  Circle (CartPt loc, String col, int radius){
    super(loc, col);
    this.radius = radius;
  }  
}

class SuperImp implements IShape{
  IShape bot;
  IShape top;
  SuperImp(IShape bot, IShape top){
   this.bot = bot;
   this.top = top;
  }
}

  
/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
D. Make examples of data.
*/

class shapeExamples{
  shapeExamples(){}
  CartPt cp1 = new CartPt(100,200);
  CartPt cp2 = new CartPt(20,50);
  CartPt cp3 = new CartPt(21312,312);
  IShape s1 = new Square(cp1,"orange",5);
  IShape s2 = new Square(cp2,"purple",50);
  IShape s3 = new Square(cp3,"red",10);
  IShape c1 = new Circle(cp3,"red",2);
  IShape r1 = new Rectangle(cp2,"pink",2,3);
  IShape sh1 = new SuperImp(c1, s1);
  IShape sh2 = new SuperImp(s2, new Square(cp1, "purple", 300));
  IShape sh3 = new SuperImp(s1, sh2);
} 

/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
2.3 Problem
We now modify the shape definitions, and design some methods.
A. Convert the data definitions for the classes that represent shapes so
that they use the IColor class hierarchy to represent the colors.
*/

interface IShape2 {
  CartPt centerOf();
  boolean contains(CartPt pt);
  double distanceTo(IShape2 s);
  boolean drawShape(Canvas c);
}

class Dot2 implements IShape2 {
  CartPt loc;
  IColor col;
  Dot2(CartPt loc,IColor col){
    this.loc = loc;
    this.col = col;
  }
  CartPt centerOf(){
    return new CartPt(this.loc.x, this.loc.y);
  }
  boolean contains(CartPt pt){
    return loc.x==pt.x&&loc.y==pt.y;
  }
  double distanceTo(IShape2 s){
    return Math.sqrt((centerOf().x - s.centerOf().x * centerOf().x - s.centerOf().x) 
                + (centerOf().x - s.centerOf().y * centerOf().x - s.centerOf().y));
  }
  boolean drawShape(Canvas c){
    return c.drawDisk(new Posn(this.loc.x, this.loc.y), 1, this.col);
  }
}

class Square2 implements IShape2 {
  CartPt loc;
  IColor col;
  int size;
  Square2(CartPt loc, IColor col, int size){
    this.loc = loc;
    this.col = col;
    this.size = size;
  }
  CartPt centerOf(){
    return new CartPt(this.loc.x+(size/2), this.loc.y+(size/2));
  }
  boolean contains(CartPt pt){
    return (loc.x < pt.x) && (pt.x < (loc.x + size)) && (loc.y < pt.y) && (pt.y < (loc.y + size));
  }
  double distanceTo(IShape2 s){
    return Math.sqrt((centerOf().x - s.centerOf().x * centerOf().x - s.centerOf().x) 
                + (centerOf().x - s.centerOf().y * centerOf().x - s.centerOf().y));
  }
  boolean drawShape(Canvas c){
    return c.drawRect(new Posn(this.loc.x, this.loc.y), this.size, this.size, this.col);
  }
}

class Rectangle2 implements IShape2 {
  CartPt loc;
  IColor col;
  int height;
  int width;
  Rectangle2(CartPt loc, IColor col, int height, int width){
    this.loc = loc;
    this.col = col;
    this.height = height;
    this.width = width;
  }
  CartPt centerOf(){
    return new CartPt(this.loc.x+(width/2), this.loc.y-(height/2));
  }
  boolean contains(CartPt pt){
    return (loc.x < pt.x) && (pt.x < (loc.x + width)) && (loc.y < pt.y) && (pt.y < (loc.y + height));
  }
  double distanceTo(IShape2 s){
    return Math.sqrt((centerOf().x - s.centerOf().x * centerOf().x - s.centerOf().x) 
                + (centerOf().x - s.centerOf().y * centerOf().x - s.centerOf().y));
  }
  boolean drawShape(Canvas c){
    return c.drawRect(new Posn(this.loc.x, this.loc.y), this.width, this.height, this.col);
  }
}

class Circle2 implements IShape2 {
  CartPt loc;
  IColor col;
  int radius;
  Circle2(CartPt loc, IColor col, int radius){
    this.loc = loc;
    this.col = col;
    this.radius = radius;
  }  
  CartPt centerOf(){
    return new CartPt(this.loc.x, this.loc.y);
  }
  boolean contains(CartPt pt){
    return distanceTo(new Dot2(new CartPt(pt.x, pt.y), new Red())) < radius;
  }
  double distanceTo(IShape2 s){
    return Math.sqrt((centerOf().x - s.centerOf().x * centerOf().x - s.centerOf().x) 
                + (centerOf().x - s.centerOf().y * centerOf().x - s.centerOf().y));
  }
  boolean drawShape(Canvas c){
    return c.drawDisk(new Posn(loc.x, loc.y), this.radius, this.col);
  }
}

class SuperImp2 implements IShape2{
  CartPt loc;
  IColor col;
  IShape2 bot;
  IShape2 top;
  SuperImp2(IShape2 bot, IShape2 top){
   this.bot = bot;
   this.top = top;
  }
  CartPt centerOf(){
    return new CartPt(this.bot.centerOf().x+(this.bot.centerOf().x-this.top.centerOf().x),
                      this.bot.centerOf().y+(this.bot.centerOf().y-this.top.centerOf().y));
  }
  boolean contains(CartPt pt){
    return top.contains(pt)||bot.contains(pt);
  }
  double distanceTo(IShape2 s){
    return Math.sqrt((centerOf().x - s.centerOf().x * centerOf().x - s.centerOf().x) 
                + (centerOf().x - s.centerOf().y * centerOf().x - s.centerOf().y));
  }
  boolean drawShape(Canvas c){
    return bot.drawShape(c) && top.drawShape(c);
  }
}
  
/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
B. Define a method toPosn that produces an instance of the class Posn
from this CartPt cartesian point.
*/

// Written above.

/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
C. Design the method centerOf() that produces the CartPt center of
this shape as follows:
 for a circle or a disk the center is already given as one of its fields
 the center of the rectangle is halfway between the left and the
right edge, and halfway between the top and the botton edge
--------- the center of the line is halfway between the two ends of the line
 the center of a combo shape if halfway between the centers of
the top and the bottom shape
*/

// Written above.
  
/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
D. Design the method contains that determines whether this shape
contains the given CartPt point.
Note: To do this correctly for the class Line requires a bit of geometri-
cal computation. You are allowed to substiute, in this case, a method
that produces false for all inputs.
*/

// Written above.
  
/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
E. Define the method distanceTo that computes the distance between
the centers of two shapes.
*/

// Written above.
  
/*    
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
F. Define the method drawShape that draws this shape in the given Canvas.
*/


class shape2Examples{
  shape2Examples(){}
  CartPt cp1 = new CartPt(100,90);
  CartPt cp2 = new CartPt(20,50);
  CartPt cp3 = new CartPt(70,70);
  IShape2 s1 = new Square2(cp1,new Red(),23);
  IShape2 s2 = new Square2(cp2,new Red(),50);
  IShape2 s3 = new Square2(cp3,new Red(),10);
  IShape2 c1 = new Circle2(cp3,new Blue(),15);
  IShape2 r1 = new Rectangle2(cp2,new Red(),2,3);
  IShape2 sh1 = new SuperImp2(c1, s1);
  IShape2 sh2 = new SuperImp2(s2, new Square2(cp1, new Red(), 300));
  IShape2 sh3 = new SuperImp2(s1, sh2);
  
  // draw a blue eye with a white pupil at the location (x, y)
  // on the given Canvas
  boolean drawCircle(Canvas c){
    return c1.drawShape(c);
  }
  
  // draw a red mouth on the given Canvas (100 by 100) 
  // assume the face will be yellow disk of radius 40
  boolean drawBox(Canvas c){
    return s1.drawShape(c);
  }
  
  boolean drawStuff(Canvas c){
    return this.drawCircle(c) &&
           this.drawBox(c);
  }
  
  Canvas c = new Canvas(200, 200);
  
  boolean showStuff = this.c.show() && this.drawStuff(c);
  
}
  
/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
2.4 Problem
Creative Project
We continue with the design of an interactive game in the style you
have done in the first course. A game consist of several different objects.
The object move either on each tick of the clock, or in response to the keys
(typically the arrow keys). There may be other changes in the game object
over the time or in response to the key events (x key launches a shot, an
animal gets hungrier as the time goes on, ...). The objects interact in some
predefined manner. Finally, something (the state of an object, the interac-
tion between objects) triggers the end of the game.
  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
A. Write down the description of the simple version of the game that has
been approved by the instructor.

Falling tiles
  A board has a time a list of tiles and a player.
  A Tile has a Location and a color
  A Player has a Location, a direction, lives, and a color
  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
B. For each object that will be used in the game do the following:
(a) Describe briefly its behavior during the game: does it change
with the clock tick?, does in respond to key events?, does it in-
teract with another object in the game?
  
  Tiles fall, there speed is determined by how long the game has gone on they
   increment in units of 30 seconds something like:
  
  Speed = -.1x^2 + 20x + 30
  
  Pixels per second, x being the number of 30 second time increments
   passed so far, Say the tick ticks four times a second you could
   just divide that coun't by 4
   t = .25?
  
  Tiles are created every time the row passes the top border, so a function
   based on there speed, the board will get new tiles, positioned above the 
   visible boundary.
  
  Players move very quickly based on which key was and/or is being pressed
   Up Down Left Right, respectively within the bounds of the board.
  
  Once a tile intersects a Player that player loses one life, there score
   is reflected on the board.
  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
(b) Identify the essential information you will need to keep track
of as the World scene changes. Design a class to represent this
information and make examples of data, especially those at the
beginning of the game, or in any expected unusual situations
during the game.
Note: I don't know whats being asked... Or what I wrote...
P. 383
*/

class Posn{
  int x;
  int y;
  Posn(int x,int y){
    this.x = x;
    this.y = y;
  }
}

class Player{
  int width = 30;
  int height = 60;
  Posn pos;
  int lives;
  String col;
  String dir;
  Player(Posn pos,int lives,String col,String dir){
    this.pos = pos;
    this.lives = lives;
    this.col = col;
    this.dir = dir;
    this.width = width;
    this.height = height;
  }
  boolean draw(Canvas c){
    c.drawRect(pos, this.width, this.height, this.col);
    return true;
  }
}

class Tile{
  int width = 30;
  int height = 60;
  Pos pos;
  String col;
  Tile(Pos pos,String col){
    this.pos = pos;
    this.col = col;
    this.width = width;
    this.height = height;
  }
  Tile fall(double s){
    return new Tile(this.x,this.y+s);
  }
  boolean draw(Canvas c){
    c.drawRect(pos, this.width, this.height, this.col);
    return true;
  }
}

// This is stupid...

interface ITileList {}

class MTLot implements ITileList {
  MTLot() {}
}

class ConsLot implements ITileList {
  Tile fst;
  ITileList rst;
  ConsLot(Tile fst, ITileList rst){
    this.fst = fst;
    this.rst = rst;
  }
}
  
/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
(c) Design the class GameWorld that includes all objects involved
in the game.
*/

class GameWorld{
  ITileList lot;
  Player p;
  GameWorld(ITileList lot,Player p){
    this.lot = lot;
    this.p = p;
  }
}
  
/*  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
(d) Make examples of the initial GameWorld and a couple of inter-
mediate worlds you expect to see in the game.
*/
  
class GameWorldExamples{
  ITileList lot1 = new MTLot();
  ITileList lot2 = new ConsLot(new Tile(new Pos(15,-30),"Red"),
                          new ConsLot(new Tile(new Pos(75,-30),"Red"),
                                      new ConsLot(new Tile(new Pos(165,-30),"Red"),
                                                 new MTLot())));
  Player p1 = new Player(new Pos(512, 585),5,"Blue","L");
  Player p2 = new Player(new Pos(512, 500),3,"Green","U");
  GameWorld ex1 = new GameWorld(lot1,p1);
  GameWorld ex2 = new GameWorld(lot2,p2);
  }

/*
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
(e) Design a picture that will represent each of the objects in your
game. A picture is composed of disks, circles (outlines), rectan-
gles, lines and text in six possible colors: red, blue, green yellow,
white, or black.
  
  
//----------------------------------------------------------------------------
//---------------------------------------------------------------------------- 
(f) Design the draw method for each object in the game and for
the whole GameWorld. The methods for each object consume
the instance of the Canvas on which the object image is to be
drawn
*/
//pg 382
//class Draw{
  //Canvas DrawTile(Canvas c){}
  //Canvas DrawPlayer(Canvas c){}
  
 // }

//pg 310
abstract class World{
  protected Canvas theCanvas = new Canvas();
  public boolean bigBang(int width, int height, double s){
    return true;
  }
  public abstract World onTick(){}
  public abstract World onKeyEvent(String key){}
  public abstract boolean draw(){}
  public World endOfWorld(String s){}
}

class TileGame extends World{
  private int WIDTH = 100;
  private int HEIGHT = 100;
  private IColor BACKGROUND = new Red();
  private ITileList tiles;
  
  // Constructor?
  public TileGame(){
    this.gameWorld = new GameWorld();
  }
  
  public void draw(){
    this.player.draw(theCanvas);
    this.tiles.draw(theCanvas);
    return;
  }
  
  public World onTick(){
    return new TileGame(this.tiles.fall());
  }
}